package cn.yunhe.servlet;

import cn.yunhe.service.OrderDetailService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

@WebServlet("/DelOrderDetailServlet")
public class DelOrderDetailServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        OrderDetailService orderDetailService=new OrderDetailService();
        List<Integer> list=new ArrayList<Integer>();
        String flag=req.getParameter("flag");
        if(flag==null){
            int eodid= Integer.parseInt(req.getParameter("eodid"));
            list.add(eodid);
        }else{
            String eodidsstr=req.getParameter("endidsstr");
            String[] eodidstr=eodidsstr.split(",");
            for (String string:eodidstr){
                Integer eodid=Integer.parseInt(string);
                list.add(eodid);
            }
        }
        orderDetailService.delShopping(list);

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req,resp);
    }
}
